import threading
import time

from NanNing.common import RadarTEST
from NanNing.common import UdpClient
from NanNing.common.testData import FormatVal


def my_thread(index):
    tag = 1
    while True:
        print(f"-------------------------------------------------------------------------\n"
              f"{index} sending message {tag}")
        with UdpClient() as client:
            client.set_data(FormatVal.CRSError)
            client.get_data_type()
            client.connect(RadarTEST.HOST, RadarTEST.PORT2)
            # client.send()
            client.main_send(is_print_log=True, is_send_sector=True, is_send_north=True)
            time.sleep(4)

            tag += 1


if __name__ == '__main__':
    for index in range(100):
        thread = threading.Thread(target=my_thread, args=(index,))
        thread.start()
